package sj.System.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import sj.System.dao.sysUser.SysUserMapper;
import sj.System.pojo.SysUser;
import sj.System.service.SysUserService;

import java.util.List;

@Transactional

public class SysUserServiceImpl implements SysUserService {


    private SysUserMapper sysUserMapper;
    public SysUserMapper getSysUserMapper() {
        return sysUserMapper;
    }

    public void setSysUserMapper(SysUserMapper sysUserMapper) {
        this.sysUserMapper = sysUserMapper;
    }

    /**
     * 增加
     *
     * @param sysUser
     * @return
     */
    @Override
    public boolean addSysUser(SysUser sysUser) {
        if(sysUserMapper.addSysUser(sysUser)==1){
            return true;
        }
        return false;
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @Override
    public boolean delSysUser(Integer id) {
        if(sysUserMapper.delSysUser(id)==1){
            return true;
        }
        return false;
    }

    /**
     * 修改
     *
     * @param sysUser
     * @return
     */
    @Override
    public boolean updateSysUser(SysUser sysUser) {
        if(sysUserMapper.updateSysUser(sysUser)==1){
            return true;
        }
        return false;
    }

    /**
     * 根据角色id删除用户信息
     *
     * @param roleId
     * @return
     */
    @Override
    public boolean delUser(Integer roleId) {
        if(sysUserMapper.delUser(roleId)==1){
            return true;
        }
        return false;
    }

    /**
     * 根据角色id查询用户信息
     *
     * @param roleId
     */
    @Override
    public List<SysUser> findUserByRoleId(Integer roleId) {
        return sysUserMapper.findUserByRoleId(roleId);
    }

}
